import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import dayjs, { Dayjs } from 'dayjs'

import api from '@/api'
const { queryChannelList } = api
export function getCompanyBasicColums(): BasicColumn[] {
  return [
    {
      title: '企业名称',
      customEllipsis: true,
      width: 240,
      fixed: 'left',
      dataIndex: 'orgName'
    },
    {
      title: '企业税号',
      align: 'left',
      width: 140,
      dataIndex: 'taxesNumber'
    },
    {
      title: '所属租户',
      customEllipsis: true,
      width: 240,
      dataIndex: 'topOrgName'
    },
    {
      title: '租户管理员手机号',
      width: 140,
      dataIndex: 'adminAccount'
    },
    {
      title: '渠道名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    {
      title: '套餐有效时间',
      align: 'right',
      width: 100,
      dataIndex: 'validTime'
    },
    {
      title: '试用状态',
      width: 90,
      dataIndex: 'tryFlag'
    },
    {
      title: '认证状态',
      width: 100,
      dataIndex: 'authStatus'
    },
    {
      title: '开票终端数量',
      width: 100,
      align: 'right',
      dataIndex: 'multipleInvoicersCount'
    },
    {
      title: '开票终端类型',
      width: 100,
      dataIndex: 'rpaType'
    },
    {
      title: '首次授权时间',
      width: 140,
      dataIndex: 'firstAuthTime'
    },
    {
      title: '创建时间',
      width: 140,
      sorter: true,
      dataIndex: 'createDate'
    },
    {
      title: '最近一次开票时间',
      width: 140,
      sorter: true,
      dataIndex: 'lastOpenTime'
    },
    {
      title: '最近一次登录时间',
      width: 140,
      sorter: true,
      dataIndex: 'lastLoginTime'
    },
    {
      title: '企业状态',
      width: 80,
      dataIndex: 'orgStatus'
    },
    {
      title: '操作',
      width: 96,
      dataIndex: 'operate',
      fixed: 'right'
    }
  ]
}
const orgStatusArr = [
  {
    label: '正常',
    value: 0,
    key: 0
  },
  {
    label: '停用',
    value: 1,
    key: 1
  }
]
const authStatusArr = [
  {
    label: '未认证',
    value: 1,
    key: 1
  },
  {
    label: '已认证',
    value: 2,
    key: 2
  },
  {
    label: '已开票',
    value: 3,
    key: 3
  }
]
const RPATypeArr = [
  {
    label: '云端基础',
    value: 1,
    key: 1
  },
  {
    label: '云端VIP',
    value: 2,
    key: 2
  },
  {
    label: '本地基础',
    value: 3,
    key: 3
  }
]
export function getSearchFormConfig(): Partial<FormProps> {
  return {
    // labelWidth: 120,
    labelCol: { style: { width: '60px', whiteSpace: 'normal', lineHeight: '14px', marginLeft: '12px' } },
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'orgName',
        label: '企业名称',
        component: 'Input',
        componentProps: {
          maxlength: 30
        }
      },
      {
        field: 'taxesNumber',
        label: '企业税号',
        component: 'Input',
        componentProps: {
          maxlength: 30
        }
      },
      {
        field: 'channelCode',
        label: '渠道名称',
        component: 'TreeSelect',
        slot: 'channelCode'
      },

      {
        field: 'topOrgName',
        label: '所属租户',
        component: 'Input',
        componentProps: {
          maxlength: 30
        }
      },
      {
        field: 'rpaType',
        label: '开票终端类型',
        component: 'Select',
        componentProps: {
          options: RPATypeArr
        }
      },
      {
        field: 'orgStatus',
        label: '企业状态',
        component: 'Select',
        componentProps: {
          options: orgStatusArr
        }
      },

      {
        field: 'authStatus',
        label: '认证状态',
        component: 'Select',
        componentProps: {
          options: authStatusArr
        }
      },
      {
        field: 'adminAccount',
        label: '租户管理员手机号',
        component: 'Input'
      },
      {
        field: 'validTime',
        label: '套餐剩余时间',
        component: 'Input',
        slot: 'validTime'
      },
      {
        field: '[createDateStart,createDateEnd]',
        label: '创建时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: '[lastOpenTimeStart,lastOpenTimeEnd]',
        label: '最近一次开票时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: '[lastLoginTimeStart,lastLoginTimeEnd]',
        label: '最近一次登录时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      }
    ]
  }
}
